#!/bin/bash
TAR=/bin/tar
bakdir="/u01/lgsa/lgsa-wareHouse-mgr/logs/"
logdir=/u02/logsBackup/logs
for dir in $bakdir
do
        cd $dir
                logname=`find . -name "aaa.log.2022-02*" -mtime +2|cut -b 3-32`
                # `为shell中的反引号，表示先执行``中的内容
                echo "============"
                echo $logname
                echo "==========="
                for ax in $logname
                do
                        $TAR -zcvf "$logdir/$ax.tar.gz" $ax
                        rm -rf $ax
                done
done